<%
 @task = task
 @user = user
 @project = project
 if(task.done==1); donestr = "done"; else; donestr=''; end
 if(task.star==1); starstr = "on"; else; starstr='off'; end
-%>
<table style="border:1px solid #AAF;background: #EEF;">

<tr><td>Done:</td><td>
<%
nb = task.subtasks_count
# can not mark this task done if contains subtasks not done
if nb == 0
-%>
<%= check_box(:task, :done,  {:onfocus => "mover('d')", :onmouseover => "mover('d')", :onchange => "change('#{task.id}',event);", :class => donestr, :id => "d#{task.id}"}) %>
<% else -%>
To be marked as done, all subtasks has to be done<br/>
(will add a super override option later....)
<% end -%>
</td></tr>

<tr><td>Project:</td><td>
<% if task.task == nil %>
<%= my_text_field_with_auto_complete(:project, :name, {:onfocus => "mover('p')",:onmouseover => "mover('p')", :id=>"p#{task.id}"}, :skip_style => true) %>
<% else %>
<%= text_field(:project, :name, {:readonly=>true, :id=>"p#{task.id}", :value=>task.task.project.name, :disabled=>true }) %>
<% end %>
</td></tr>
<tr><td>Priority:</td><td><%=text_field(:task, :priority, {:onfocus => "mover('pr')",:onmouseover => "mover('pr',this.value)",:size => 1, :class => donestr, :id => "pr#{task.id}"}) %></td></tr>
<tr><td valign="top">Task:</td><td><%=text_area(:task, :title, {:onfocus => "mover('t')",:onmouseover => "mover('t',this.value)",:cols => 60, :rows => 4, :class => donestr, :id => "t#{task.id}"}) %></td></tr>
<tr><td>Assigned:</td><td><%=my_text_field_with_auto_complete(:user, :name, {:onfocus => "mover('r')",:onmouseover => "mover('r')", :id=>"r#{task.id}"}, :skip_style => true) %></td></tr>
<tr><td>Deadline:</td><td><%=text_field(:task, :duedate, {:onfocus => "dispcal('#{task.id}',this.value);",:onmouseover => "mover('da')",:size => 10, :class => donestr, :id => "da#{task.id}"}) %>
<%= render(:partial => 'task/deadline', :locals => {:task=>task}) %>
</td></tr>

<tr><td>State:</td><td>
<%=radio_button(:task,:state, 'next', :disabled=>!is_my_task)%> next
<%=radio_button(:task,:state, 'waiting', :disabled=>!is_my_task)%> waiting
<%=radio_button(:task,:state, 'maybe', :disabled=>!is_my_task)%> maybe
<%=radio_button(:task,:state, 'ref', :disabled=>!is_my_task)%> ref
</td></tr>

<tr bgcolor="#DDF">

<td>Time:</td>
<td>
orig est
<%=text_field(:task, :orig_est,{:size => 2, :class => donestr, :id => "initest#{task.id}"}) %>
curr est
<%=text_field(:task, :cur_est,{:size => 2, :class => donestr, :id => "curest#{task.id}"}) %>
elapsed
<%=text_field(:task, :elapsed,{:size => 2, :class => donestr, :id => "timeused#{task.id}"}) %>

<% if task.remains == nil %>

in hours

<% else %>
remains:
<%= task.remains %>
all:
<%= task.subremains %><br/>
<% end %>

<%if nb > 0 %>
This task has <%= nb %> subtasks. The remaining time will take the subtasks time into account.
<% end %>
</td>

</tr>

<tr><td></td><td>
<a href="#" onmouseover="mover('s')" onclick="save('<%=task.id%>','<%=item_name%>');return false;"><img id="s<%=task.id%>" src="/images/save.png" border="0"></a>
<a href="#" onmouseover="mover('n')" onclick="notes(<%=task.id%>);return false;"><img id="n<%=task.id%>" src="/images/notes.png" border="0"></a>
<a href="#" onmouseover="mover('de')" onclick="del('<%=task.id%>','<%=item_name%>');return false;"><img id="de_<%=item_name%>_<%=task.id%>" src="/images/delete.gif" border="0"></a>
<div style="display:inline" id="deadline<%=task.id%>">
</div>
<% if(task.notes_count > 0) -%>
(<%= task.notes_count -%> notes)
<% end -%>
<div class="tags" id="tag<%=task.id%>"><%=task.tags.map{|t| t.name }.join(", ")%></div>
<div id="done_on_<%=task.id%>" class="done_on"><% if task.done_on %>done <%= time_ago_in_words(task.done_on) %> ago<% end %></div>
</td></tr>
</table>
<script>$('t<%=task.id%>').focus();</script>
